<meta charset="UTF-8">
<?php
include_once("../functions/db_manipulate.php");

if (!init()) {
    redirect("?action=login");
}
connectDB();

startTransaction();

$initiatorAction = \controller\ControllerUtil::getEncodedActionFromUrlWithParameters($_SERVER['HTTP_REFERER']);

$resultSet = null;

if ($_POST['galvis'] == "true") {

    $resultSet = mysql_query("UPDATE users SET visible='1' WHERE id='" . $_SESSION['id'] . "'");
} else if ($_POST['galvis'] == "false") {
    $resultSet = mysql_query("UPDATE users SET visible='0' WHERE id='" . $_SESSION['id'] . "'");
}

//else {
//    redirect($_SERVER['HTTP_REFERER']);
//}

if ($resultSet) {
    commitTransaction();
} else {
    rollbackTransaction();
}

redirect($_SERVER['HTTP_REFERER']);
